/**
 * Im用户管理 api js文件
 */

import request from "@/utils/request";

/**
 * 查询IM用户的分页数据
 * @param {*} params
 * @returns
 */
export function queryPages(params) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/imUser/pages",
    method: "get",
    params: params
  });
}

/**
 * 校验账号是否存在
 * @param {*} loginAccount
 * @returns
 */
export function hasExistByLoginAccount(loginAccount) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/imUser/hasExistByLoginAccount/${loginAccount}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 保存或修改数据
 * @param {*} data
 */
export function saveOrUpdate(data) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/imUser/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 根据ID查询用户数据
 * @param {*} id
 */
export function getById(id) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + `/yxpz/imUser/getById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 切换状态
 * @param {*} id
 * @param {*} stateFlag
 * @returns
 */
export function tiggerStateFlag(id, stateFlag) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/imUser/tiggerStateFlag",
    method: "get",
    params: {
      id,
      stateFlag
    }
  });
}

/**
 * 删除用户数据
 * @param {*} id
 * @returns
 */
export function deleteUser(id) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + `/yxpz/imUser/deleteUser/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 重置密码 123456
 * @param {*} id
 */
export function resetPassword(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + `/yxpz/imUser/resetPassword/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 根据queryByDistrictCode 区划code查询下面的通讯im用户集合
 * @param {*} districtCode
 * @returns
 */
export function queryByDistrictCode(districtCode) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/imUser/queryByDistrictCode/${districtCode}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 查询IM用户树
 * @param {*} params
 * @returns
 */
export function getImUserTree(params) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/imUser/getImUserTree",
    method: "get",
    params: params
  });
}

/**
 * im登录接口
 * @param {*} data
 * @returns
 */
export function imLogin(data) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + `/yxpz/imUser/imLogin`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}
